#include "filterPages.h"
#include <iostream>

#define MASK_MAX 301

GrayScalePage::GrayScalePage(QWidget *parent) : QWidget(parent){
}







NegativePage::NegativePage(QWidget *parent) : QWidget(parent){
}







LogPage::LogPage(QWidget *parent) : QWidget(parent){
}







PowerPage::PowerPage(QWidget *_parent) : QWidget(_parent){
    gamma = 1.0;

	QLabel* gammaLabel = new QLabel(tr("Gamma:"));
	QDoubleSpinBox *gammaDoubleSpinBox = new QDoubleSpinBox();
    gammaDoubleSpinBox->setRange(0.0, 20.0);
    gammaDoubleSpinBox->setSingleStep(0.25);
    gammaDoubleSpinBox->setValue(gamma);
    connect(gammaDoubleSpinBox, SIGNAL(valueChanged(double)), this, SLOT(changeGamma(double)));


    QHBoxLayout *mainLayout = new QHBoxLayout;
    mainLayout->addWidget(gammaLabel);
    mainLayout->addWidget(gammaDoubleSpinBox);
	mainLayout->addStretch();

    setLayout(mainLayout);
}

void PowerPage::changeGamma(double _g){
    gamma = _g;
    done();
}

double PowerPage::getGamma(){
    return gamma;
}







ThresholdingPage::ThresholdingPage(QWidget *_parent) : QWidget(_parent){
    threshold = 127;

	QLabel* thresholdLabel = new QLabel(tr("Threshold:"));

    QSpinBox *thresholdSpinBox = new QSpinBox();
    thresholdSpinBox->setRange(0, 255);
    thresholdSpinBox->setSingleStep(5);
    thresholdSpinBox->setValue(threshold);
    connect(thresholdSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changeThreshold(int)));

    QHBoxLayout *mainLayout = new QHBoxLayout;
    mainLayout->addWidget(thresholdLabel);
    mainLayout->addWidget(thresholdSpinBox);
	mainLayout->addStretch();

    setLayout(mainLayout);
}

void ThresholdingPage::changeThreshold(int _t){
    threshold = _t;
    done();
}

int ThresholdingPage::getThreshold(){
    return threshold;
}







HistogramEqualizationPage::HistogramEqualizationPage(QWidget *parent) : QWidget(parent){
}







HistogramMatchingPage::HistogramMatchingPage(QWidget *parent) : QWidget(parent){
    QLabel* matchingLabel = new QLabel(QString::fromUtf8("Especificação: [ainda precisa ser implementada]"));

    QHBoxLayout *mainLayout = new QHBoxLayout;
    mainLayout->addWidget(matchingLabel);
	mainLayout->addStretch();

    setLayout(mainLayout);
}







LocalHistogramProcessingPage::LocalHistogramProcessingPage(QWidget *_parent) : QWidget(_parent){
    m = n = 3;

	QLabel* maskLabel = new QLabel(tr("Tamanho da mascara: "));
	QLabel* mLabel = new QLabel(tr("m:"));
	QLabel* nLabel = new QLabel(tr("n:"));

    QSpinBox *mSpinBox = new QSpinBox();
    mSpinBox->setRange(1, MASK_MAX);
    mSpinBox->setSingleStep(2);
    mSpinBox->setValue(m);
    connect(mSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changeM(int)));

    QSpinBox *nSpinBox = new QSpinBox();
    nSpinBox->setRange(1, MASK_MAX);
    nSpinBox->setSingleStep(2);
    nSpinBox->setValue(n);
    connect(nSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changeN(int)));

	tryItButton = new QPushButton(tr("Testar"),this);
    connect(tryItButton, SIGNAL(clicked()), this, SLOT(tryIt()));


    QHBoxLayout *maskLayout = new QHBoxLayout;
    maskLayout->addWidget(maskLabel);
    maskLayout->addWidget(mLabel);
    maskLayout->addWidget(mSpinBox);
	maskLayout->addStretch(2);
    maskLayout->addWidget(nLabel);
    maskLayout->addWidget(nSpinBox);
	maskLayout->addStretch(100);

    QHBoxLayout *buttomLayout = new QHBoxLayout;
	buttomLayout->addWidget(tryItButton, 0, Qt::AlignRight);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addLayout(maskLayout);
	mainLayout->addStretch();
    mainLayout->addLayout(buttomLayout);
	mainLayout->addStretch();

    setLayout(mainLayout);
}

void LocalHistogramProcessingPage::changeM(int _m){
    m = _m;
}

void LocalHistogramProcessingPage::changeN(int _n){
    n = _n;
}

void LocalHistogramProcessingPage::tryIt(){
    tryItButton->setEnabled(false);
    done();
}

void LocalHistogramProcessingPage::tryItAgain(){
    tryItButton->setEnabled(true);
}

int LocalHistogramProcessingPage::getM(){
    return m;
}

int LocalHistogramProcessingPage::getN(){
    return n;
}







LocalHistogramProcessingWithStatisticsPage::LocalHistogramProcessingWithStatisticsPage(QWidget *_parent) : QWidget(_parent){
    m = n = 3;
    k0 = 0.4;
    k1 = 0.02;
    k2 = 0.4;
    e = 4.0;

	QLabel* maskLabel = new QLabel(tr("Tamanho da mascara: "));
	QLabel* mLabel = new QLabel(tr("m:"));
	QLabel* nLabel = new QLabel(tr("n:"));
	QLabel* kLabel = new QLabel(QString::fromUtf8("Definições: "));
	QLabel* k0Label = new QLabel(tr("k0:"));
	QLabel* k1Label = new QLabel(tr("k1:"));
	QLabel* k2Label = new QLabel(tr("k2:"));
	QLabel* eLabel = new QLabel(tr("E:"));

    QSpinBox *mSpinBox = new QSpinBox();
    mSpinBox->setRange(1, MASK_MAX);
    mSpinBox->setSingleStep(2);
    mSpinBox->setValue(m);
    connect(mSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changeM(int)));

    QSpinBox *nSpinBox = new QSpinBox();
    nSpinBox->setRange(1, MASK_MAX);
    nSpinBox->setSingleStep(2);
    nSpinBox->setValue(n);
    connect(nSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changeN(int)));

	QDoubleSpinBox *k0DoubleSpinBox = new QDoubleSpinBox();
    k0DoubleSpinBox->setRange(0.0, 1.0);
    k0DoubleSpinBox->setSingleStep(0.1);
    k0DoubleSpinBox->setValue(k0);
    connect(k0DoubleSpinBox, SIGNAL(valueChanged(double)), this, SLOT(changeK0(double)));

	k1DoubleSpinBox = new QDoubleSpinBox();
    k1DoubleSpinBox->setRange(0.0, k2-0.01);
    k1DoubleSpinBox->setSingleStep(0.1);
    k1DoubleSpinBox->setValue(k1);
    connect(k1DoubleSpinBox, SIGNAL(valueChanged(double)), this, SLOT(changeK1(double)));

	QDoubleSpinBox *k2DoubleSpinBox = new QDoubleSpinBox();
    k2DoubleSpinBox->setRange(0.0, 100.0);
    k2DoubleSpinBox->setSingleStep(0.1);
    k2DoubleSpinBox->setValue(k2);
    connect(k2DoubleSpinBox, SIGNAL(valueChanged(double)), this, SLOT(changeK2(double)));

	QDoubleSpinBox *eDoubleSpinBox = new QDoubleSpinBox();
    eDoubleSpinBox->setRange(0.0, 100.0);
    eDoubleSpinBox->setSingleStep(0.5);
    eDoubleSpinBox->setValue(e);
    connect(eDoubleSpinBox, SIGNAL(valueChanged(double)), this, SLOT(changeE(double)));

	tryItButton = new QPushButton(tr("Testar"),this);
    connect(tryItButton, SIGNAL(clicked()), this, SLOT(tryIt()));

    QHBoxLayout *mnLayout = new QHBoxLayout;
    mnLayout->addWidget(maskLabel);
    mnLayout->addWidget(mLabel);
    mnLayout->addWidget(mSpinBox);
    mnLayout->addStretch(2);
    mnLayout->addWidget(nLabel);
    mnLayout->addWidget(nSpinBox);
    mnLayout->addStretch(100);

    QHBoxLayout *kLayout = new QHBoxLayout;
    kLayout->addWidget(kLabel);
    kLayout->addWidget(k0Label);
    kLayout->addWidget(k0DoubleSpinBox);
	kLayout->addStretch(2);
    kLayout->addWidget(k1Label);
    kLayout->addWidget(k1DoubleSpinBox);
	kLayout->addStretch(2);
    kLayout->addWidget(k2Label);
    kLayout->addWidget(k2DoubleSpinBox);
	kLayout->addStretch(2);
    kLayout->addWidget(eLabel);
    kLayout->addWidget(eDoubleSpinBox);
	kLayout->addStretch(100);

    QHBoxLayout *buttomLayout = new QHBoxLayout;
	buttomLayout->addWidget(tryItButton, 0, Qt::AlignRight);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addLayout(mnLayout);
	mainLayout->addStretch();
    mainLayout->addLayout(kLayout);
	mainLayout->addStretch();
    mainLayout->addLayout(buttomLayout);
	mainLayout->addStretch();

    setLayout(mainLayout);
}

void LocalHistogramProcessingWithStatisticsPage::changeM(int _m){
    m = _m;
}

void LocalHistogramProcessingWithStatisticsPage::changeN(int _n){
    n = _n;
}

void LocalHistogramProcessingWithStatisticsPage::changeK0(double _k){
    k0 = _k;
}

void LocalHistogramProcessingWithStatisticsPage::changeK1(double _k){
    if (_k < k2)
        k1 = _k;
}

void LocalHistogramProcessingWithStatisticsPage::changeK2(double _k){
    k2 = _k;
    k1DoubleSpinBox->setRange(0, k2 - 0.01);
}

void LocalHistogramProcessingWithStatisticsPage::changeE(double _e){
    e = _e;
}

void LocalHistogramProcessingWithStatisticsPage::tryIt(){
    tryItButton->setEnabled(false);
    done();
}

void LocalHistogramProcessingWithStatisticsPage::tryItAgain(){
    tryItButton->setEnabled(true);
}

int LocalHistogramProcessingWithStatisticsPage::getM(){
    return m;
}

int LocalHistogramProcessingWithStatisticsPage::getN(){
    return n;
}

double LocalHistogramProcessingWithStatisticsPage::getK0(){
    return k0;
}

double LocalHistogramProcessingWithStatisticsPage::getK1(){
    return k1;
}

double LocalHistogramProcessingWithStatisticsPage::getK2(){
    return k2;
}

double LocalHistogramProcessingWithStatisticsPage::getE(){
    return e;
}







AveragePage::AveragePage(QWidget *_parent) : QWidget(_parent){
    m = n = 3;

	QLabel* maskLabel = new QLabel(tr("Tamanho da mascara: "));
	QLabel* mLabel = new QLabel(tr("m:"));
	QLabel* nLabel = new QLabel(tr("n:"));

    QSpinBox *mSpinBox = new QSpinBox();
    mSpinBox->setRange(1, MASK_MAX);
    mSpinBox->setSingleStep(2);
    mSpinBox->setValue(m);
    connect(mSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changeM(int)));

    QSpinBox *nSpinBox = new QSpinBox();
    nSpinBox->setRange(1, MASK_MAX);
    nSpinBox->setSingleStep(2);
    nSpinBox->setValue(n);
    connect(nSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changeN(int)));

	tryItButton = new QPushButton(tr("Testar"),this);
    connect(tryItButton, SIGNAL(clicked()), this, SLOT(tryIt()));


    QHBoxLayout *maskLayout = new QHBoxLayout;
    maskLayout->addWidget(maskLabel);
    maskLayout->addWidget(mLabel);
    maskLayout->addWidget(mSpinBox);
	maskLayout->addStretch(2);
    maskLayout->addWidget(nLabel);
    maskLayout->addWidget(nSpinBox);
	maskLayout->addStretch(100);

    QHBoxLayout *buttomLayout = new QHBoxLayout;
	buttomLayout->addWidget(tryItButton, 0, Qt::AlignRight);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addLayout(maskLayout);
	mainLayout->addStretch();
    mainLayout->addLayout(buttomLayout);
	mainLayout->addStretch();

    setLayout(mainLayout);
}

void AveragePage::changeM(int _m){
    m = _m;
}

void AveragePage::changeN(int _n){
    n = _n;
}

void AveragePage::tryIt(){
    tryItButton->setEnabled(false);
    done();
}

void AveragePage::tryItAgain(){
    tryItButton->setEnabled(true);
}

int AveragePage::getM(){
    return m;
}

int AveragePage::getN(){
    return n;
}







WeightedAveragePage::WeightedAveragePage(QWidget *_parent) : QWidget(_parent){
    m = n = 3;

	QLabel* maskLabel = new QLabel(tr("Tamanho da mascara: "));
	QLabel* mLabel = new QLabel(tr("m:"));
	QLabel* nLabel = new QLabel(tr("n:"));

    QSpinBox *mSpinBox = new QSpinBox();
    mSpinBox->setRange(1, MASK_MAX);
    mSpinBox->setSingleStep(2);
    mSpinBox->setValue(m);
    connect(mSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changeM(int)));

    QSpinBox *nSpinBox = new QSpinBox();
    nSpinBox->setRange(1, MASK_MAX);
    nSpinBox->setSingleStep(2);
    nSpinBox->setValue(n);
    connect(nSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changeN(int)));

	tryItButton = new QPushButton(tr("Testar"),this);
    connect(tryItButton, SIGNAL(clicked()), this, SLOT(tryIt()));


    QHBoxLayout *maskLayout = new QHBoxLayout;
    maskLayout->addWidget(maskLabel);
    maskLayout->addWidget(mLabel);
    maskLayout->addWidget(mSpinBox);
	maskLayout->addStretch(2);
    maskLayout->addWidget(nLabel);
    maskLayout->addWidget(nSpinBox);
	maskLayout->addStretch(100);

    QHBoxLayout *buttomLayout = new QHBoxLayout;
	buttomLayout->addWidget(tryItButton, 0, Qt::AlignRight);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addLayout(maskLayout);
	mainLayout->addStretch();
    mainLayout->addLayout(buttomLayout);
	mainLayout->addStretch();

    setLayout(mainLayout);
}

void WeightedAveragePage::changeM(int _m){
    m = _m;
}

void WeightedAveragePage::changeN(int _n){
    n = _n;
}

void WeightedAveragePage::tryIt(){
    tryItButton->setEnabled(false);
    done();
}

void WeightedAveragePage::tryItAgain(){
    tryItButton->setEnabled(true);
}

int WeightedAveragePage::getM(){
    return m;
}

int WeightedAveragePage::getN(){
    return n;
}







GaussianPage::GaussianPage(QWidget *_parent) : QWidget(_parent){
    m = n = 3;
    sigma = 1.0;

	QLabel* maskLabel = new QLabel(tr("Tamanho da mascara: "));
	QLabel* mLabel = new QLabel(tr("m:"));
	QLabel* nLabel = new QLabel(tr("n:"));
	QLabel* sigmaLabel = new QLabel(tr("Sigma:"));

    QSpinBox *mSpinBox = new QSpinBox();
    mSpinBox->setRange(1, MASK_MAX);
    mSpinBox->setSingleStep(2);
    mSpinBox->setValue(m);
    connect(mSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changeM(int)));

    QSpinBox *nSpinBox = new QSpinBox();
    nSpinBox->setRange(1, MASK_MAX);
    nSpinBox->setSingleStep(2);
    nSpinBox->setValue(n);
    connect(nSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changeN(int)));

	QDoubleSpinBox *sigmaDoubleSpinBox = new QDoubleSpinBox();
    sigmaDoubleSpinBox->setRange(0.01, 500.0);
    sigmaDoubleSpinBox->setSingleStep(1);
    sigmaDoubleSpinBox->setValue(sigma);
    connect(sigmaDoubleSpinBox, SIGNAL(valueChanged(double)), this, SLOT(changeSigma(double)));

	tryItButton = new QPushButton(tr("Testar"),this);
    connect(tryItButton, SIGNAL(clicked()), this, SLOT(tryIt()));


    QHBoxLayout *maskLayout = new QHBoxLayout;
    maskLayout->addWidget(maskLabel);
    maskLayout->addWidget(mLabel);
    maskLayout->addWidget(mSpinBox);
	maskLayout->addStretch(2);
    maskLayout->addWidget(nLabel);
    maskLayout->addWidget(nSpinBox);
	maskLayout->addStretch(100);

    QHBoxLayout *sigmaLayout = new QHBoxLayout;
    sigmaLayout->addWidget(sigmaLabel);
    sigmaLayout->addWidget(sigmaDoubleSpinBox);
	sigmaLayout->addStretch(100);

    QHBoxLayout *buttomLayout = new QHBoxLayout;
	buttomLayout->addWidget(tryItButton, 0, Qt::AlignRight);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addLayout(maskLayout);
	mainLayout->addStretch();
    mainLayout->addLayout(sigmaLayout);
	mainLayout->addStretch();
    mainLayout->addLayout(buttomLayout);
	mainLayout->addStretch();

    setLayout(mainLayout);
}

void GaussianPage::changeM(int _m){
    m = _m;
}

void GaussianPage::changeN(int _n){
    n = _n;
}

void GaussianPage::changeSigma(double _s){
    sigma = _s;
}

void GaussianPage::tryIt(){
    tryItButton->setEnabled(false);
    done();
}

void GaussianPage::tryItAgain(){
    tryItButton->setEnabled(true);
}

int GaussianPage::getM(){
    return m;
}

int GaussianPage::getN(){
    return n;
}

double GaussianPage::getSigma(){
    return sigma;
}







OrderStatisticPage::OrderStatisticPage(QWidget *_parent) : QWidget(_parent){
    m = n = 3;
    position = 0;

	QLabel* maskLabel = new QLabel(tr("Tamanho da mascara: "));
	QLabel* mLabel = new QLabel(tr("m:"));
	QLabel* nLabel = new QLabel(tr("n:"));
	QLabel* positionLabel = new QLabel(tr("Tipo:"));

    QSpinBox *mSpinBox = new QSpinBox();
    mSpinBox->setRange(1, MASK_MAX);
    mSpinBox->setSingleStep(2);
    mSpinBox->setValue(m);
    connect(mSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changeM(int)));

    QSpinBox *nSpinBox = new QSpinBox();
    nSpinBox->setRange(1, MASK_MAX);
    nSpinBox->setSingleStep(2);
    nSpinBox->setValue(n);
    connect(nSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changeN(int)));

    QComboBox *positionComboBox = new QComboBox;
    positionComboBox->addItem(tr("Mediana"));
    positionComboBox->addItem(tr("Max"));
    positionComboBox->addItem(tr("Min"));
    connect(positionComboBox, SIGNAL(activated(int)), this, SLOT(changePosition(int)));

	tryItButton = new QPushButton(tr("Testar"),this);
    connect(tryItButton, SIGNAL(clicked()), this, SLOT(tryIt()));


    QHBoxLayout *positionLayout = new QHBoxLayout;
    positionLayout->addWidget(positionLabel);
    positionLayout->addWidget(positionComboBox);
	positionLayout->addStretch(100);

    QHBoxLayout *maskLayout = new QHBoxLayout;
    maskLayout->addWidget(maskLabel);
    maskLayout->addWidget(mLabel);
    maskLayout->addWidget(mSpinBox);
	maskLayout->addStretch(2);
    maskLayout->addWidget(nLabel);
    maskLayout->addWidget(nSpinBox);
	maskLayout->addStretch(100);

    QHBoxLayout *buttomLayout = new QHBoxLayout;
	buttomLayout->addWidget(tryItButton, 0, Qt::AlignRight);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addLayout(positionLayout);
	mainLayout->addStretch();
    mainLayout->addLayout(maskLayout);
	mainLayout->addStretch();
    mainLayout->addLayout(buttomLayout);
	mainLayout->addStretch();

    setLayout(mainLayout);
}

void OrderStatisticPage::changeM(int _m){
    m = _m;
}

void OrderStatisticPage::changeN(int _n){
    n = _n;
}

void OrderStatisticPage::changePosition(int _index){
    position = _index;
}

void OrderStatisticPage::tryIt(){
    tryItButton->setEnabled(false);
    done();
}

void OrderStatisticPage::tryItAgain(){
    tryItButton->setEnabled(true);
}

int OrderStatisticPage::getM(){
    return m;
}

int OrderStatisticPage::getN(){
    return n;
}

int OrderStatisticPage::getPosition(){
    switch(position){
        case 0:
            return (m*n - 1) / 2;
            break;
        case 1:
            return m*n - 1;
            break;
        case 2:
            return 0;
            break;
    }
    return 0;
}







LaplacianPage::LaplacianPage(QWidget *_parent) : QWidget(_parent){
    type1 = type2 = 0;

	QLabel* type1Label = new QLabel(QString::fromUtf8("Vizinhança:"));
	QLabel* type2Label = new QLabel(tr("Centro:"));

    QComboBox *type1ComboBox = new QComboBox;
    type1ComboBox->addItem(QString::fromUtf8("4"));
    type1ComboBox->addItem(QString::fromUtf8("8"));
    connect(type1ComboBox, SIGNAL(activated(int)), this, SLOT(changeType1(int)));

    QComboBox *type2ComboBox = new QComboBox;
    type2ComboBox->addItem(QString::fromUtf8("negativo"));
    type2ComboBox->addItem(QString::fromUtf8("positivo"));
    connect(type2ComboBox, SIGNAL(activated(int)), this, SLOT(changeType2(int)));

	tryItButton = new QPushButton(tr("Testar"),this);
    connect(tryItButton, SIGNAL(clicked()), this, SLOT(tryIt()));


    QHBoxLayout *typeLayout = new QHBoxLayout;
    typeLayout->addWidget(type1Label);
    typeLayout->addWidget(type1ComboBox);
	typeLayout->addStretch(2);
    typeLayout->addWidget(type2Label);
    typeLayout->addWidget(type2ComboBox);
	typeLayout->addStretch(100);

    QHBoxLayout *buttomLayout = new QHBoxLayout;
	buttomLayout->addWidget(tryItButton, 0, Qt::AlignRight);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addLayout(typeLayout);
	mainLayout->addStretch();
    mainLayout->addLayout(buttomLayout);
	mainLayout->addStretch();

    setLayout(mainLayout);
}

void LaplacianPage::changeType1(int _index){
    type1 = _index;
}

void LaplacianPage::changeType2(int _index){
    type2 = _index;
}

void LaplacianPage::tryIt(){
    tryItButton->setEnabled(false);
    done();
}

void LaplacianPage::tryItAgain(){
    tryItButton->setEnabled(true);
}

int LaplacianPage::getType1(){
    return type1;
}

int LaplacianPage::getType2(){
    return type2;
}







UnsharpMaskingAndHighboostPage::UnsharpMaskingAndHighboostPage(QWidget *_parent) : QWidget(_parent){
    m = n = 3;
    sigma = 1.0;

	QLabel* maskLabel = new QLabel(tr("Tamanho da mascara: "));
	QLabel* mLabel = new QLabel(tr("m:"));
	QLabel* nLabel = new QLabel(tr("n:"));
	sigmaLabel = new QLabel(tr("Sigma:"));
	QLabel* typeLabel = new QLabel(QString::fromUtf8("Tipo de suaviação:"));
	sigmaLabel->hide();

    QSpinBox *mSpinBox = new QSpinBox();
    mSpinBox->setRange(1, MASK_MAX);
    mSpinBox->setSingleStep(2);
    mSpinBox->setValue(m);
    connect(mSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changeM(int)));

    QSpinBox *nSpinBox = new QSpinBox();
    nSpinBox->setRange(1, MASK_MAX);
    nSpinBox->setSingleStep(2);
    nSpinBox->setValue(n);
    connect(nSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changeN(int)));

	sigmaDoubleSpinBox = new QDoubleSpinBox();
    sigmaDoubleSpinBox->setRange(0.01, 500.0);
    sigmaDoubleSpinBox->setSingleStep(1);
    sigmaDoubleSpinBox->setValue(sigma);
    connect(sigmaDoubleSpinBox, SIGNAL(valueChanged(double)), this, SLOT(changeSigma(double)));
    sigmaDoubleSpinBox->hide();

    QComboBox *typeComboBox = new QComboBox;
    typeComboBox->addItem(QString::fromUtf8("Média"));
    typeComboBox->addItem(QString::fromUtf8("Média ponderada"));
    typeComboBox->addItem(QString::fromUtf8("Gaussiana"));
    connect(typeComboBox, SIGNAL(activated(int)), this, SLOT(changeType(int)));

	tryItButton = new QPushButton(tr("Testar"),this);
    connect(tryItButton, SIGNAL(clicked()), this, SLOT(tryIt()));

    QHBoxLayout *maskLayout = new QHBoxLayout;
    maskLayout->addWidget(maskLabel);
    maskLayout->addWidget(mLabel);
    maskLayout->addWidget(mSpinBox);
	maskLayout->addStretch(2);
    maskLayout->addWidget(nLabel);
    maskLayout->addWidget(nSpinBox);
	maskLayout->addStretch(100);

    QHBoxLayout *typeSigmaLayout = new QHBoxLayout;
    typeSigmaLayout->addWidget(typeLabel);
    typeSigmaLayout->addWidget(typeComboBox);
	typeSigmaLayout->addStretch(2);
    typeSigmaLayout->addWidget(sigmaLabel);
    typeSigmaLayout->addWidget(sigmaDoubleSpinBox);
	typeSigmaLayout->addStretch(100);

    QHBoxLayout *buttomLayout = new QHBoxLayout;
	buttomLayout->addWidget(tryItButton, 0, Qt::AlignRight);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addLayout(maskLayout);
	mainLayout->addStretch();
    mainLayout->addLayout(typeSigmaLayout);
	mainLayout->addStretch();
    mainLayout->addLayout(buttomLayout);
	mainLayout->addStretch();

    setLayout(mainLayout);
}

void UnsharpMaskingAndHighboostPage::changeM(int _m){
    m = _m;
}

void UnsharpMaskingAndHighboostPage::changeN(int _n){
    n = _n;
}

void UnsharpMaskingAndHighboostPage::changeSigma(double _s){
    sigma = _s;
}

void UnsharpMaskingAndHighboostPage::changeType(int _index){
    type = _index;
    if(type == 2){
        sigmaDoubleSpinBox->show();
        sigmaLabel->show();
    }
    else{
        sigmaDoubleSpinBox->hide();
        sigmaLabel->hide();
    }
}

void UnsharpMaskingAndHighboostPage::tryIt(){
    tryItButton->setEnabled(false);
    done();
}

void UnsharpMaskingAndHighboostPage::tryItAgain(){
    tryItButton->setEnabled(true);
}

int UnsharpMaskingAndHighboostPage::getM(){
    return m;
}

int UnsharpMaskingAndHighboostPage::getN(){
    return n;
}

double UnsharpMaskingAndHighboostPage::getSigma(){
    return sigma;
}

int UnsharpMaskingAndHighboostPage::getType(){
    return type;
}







GradientPage::GradientPage(QWidget *_parent) : QWidget(_parent){
    type = 0;

	QLabel* typeLabel = new QLabel(QString::fromUtf8("Tipo de operador:"));

    QComboBox *typeComboBox = new QComboBox;
    typeComboBox->addItem(QString::fromUtf8("Cruzado de Roberts"));
    typeComboBox->addItem(QString::fromUtf8("Sobel"));
    connect(typeComboBox, SIGNAL(activated(int)), this, SLOT(changeType(int)));

	tryItButton = new QPushButton(tr("Testar"),this);
    connect(tryItButton, SIGNAL(clicked()), this, SLOT(tryIt()));

    QHBoxLayout *typeLayout = new QHBoxLayout;
    typeLayout->addWidget(typeLabel);
    typeLayout->addWidget(typeComboBox);
	typeLayout->addStretch(100);

    QHBoxLayout *buttomLayout = new QHBoxLayout;
	buttomLayout->addWidget(tryItButton, 0, Qt::AlignRight);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addLayout(typeLayout);
	mainLayout->addStretch();
    mainLayout->addLayout(buttomLayout);
	mainLayout->addStretch();

    setLayout(mainLayout);
}

void GradientPage::changeType(int _index){
    type = _index;
}

void GradientPage::tryIt(){
    tryItButton->setEnabled(false);
    done();
}

void GradientPage::tryItAgain(){
    tryItButton->setEnabled(true);
}

int GradientPage::getType(){
    return type;
}
